package web;

import com.alibaba.fastjson.JSON;
import pojo.Brand;
import service.brandService.brandService;
import service.brandServiceImpl.brandServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;

@WebServlet("/updateServlet")
public class updateServlet extends HttpServlet {
    brandService brandservice=new brandServiceImpl();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        BufferedReader br = req.getReader();//获取请求体数据（修改后的对象）
        String s = br.readLine();
        Brand brand = JSON.parseObject(s, Brand.class);
        brandservice.update(brand);
        resp.getWriter().write("yes");//提交成功后返回yes
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }
}
